import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { MallGoods } from '@/entities/MallGoods';
import { Repository } from 'typeorm';
import { PageQuery, PageResult } from '@/common/interfaces/Pagination';
import { BuildPagination } from '@/common/utils/page.heler';

@Injectable()
export class GoodsService {
  constructor(@InjectRepository(MallGoods) private readonly repository: Repository<MallGoods>) {}

  async clientsPageQuery(params: PageQuery): Promise<PageResult<MallGoods>> {
    return BuildPagination(this.repository.createQueryBuilder(), params);
  }

  async findById(id: number) {
    return this.repository.findOne(id);
  }
}
